/**
 * 
 */
package com.android.contacts;

import android.content.ContentResolver;
import android.content.Intent;
import android.database.Cursor;
import android.os.Build;

import com.android.contacts.model.vo.ContactList;

/**
 * @author Amit
 * 
 */
public abstract class ContactAPI {

	private static ContactAPI mContactAPI;

	private Cursor mCursor;
	private ContentResolver mContentResolver;

	public static ContactAPI getContactAPI() {
		if (mContactAPI == null) {
			String apiClass;
			if (Integer.parseInt(Build.VERSION.SDK) >= Build.VERSION_CODES.ECLAIR) {
				apiClass = "com.android.contacts.ContactsApiSdk5";
			} else {
				apiClass = "com.android.contacts.ContactsApiSdk7";
			}

			try {
				Class<? extends ContactAPI> realClass = Class.forName(apiClass)
						.asSubclass(ContactAPI.class);
				mContactAPI = realClass.newInstance();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			} catch (InstantiationException e) {
				e.printStackTrace();
			}
		}
		return mContactAPI;
	}

	public abstract Intent getContactIntent();

	public abstract ContactList getContactList();

	public abstract Cursor getCursor();

	public abstract void setCusror(Cursor cursor);

	public abstract ContentResolver getContentResolver();

	public abstract void setContentResolver(ContentResolver contentResolver);

}
